***********************************************************
* Internal migration and crime in Brazil *
* Author: Eva-Maria Egger 

* Contact: egger@wider.unu.edu
***********************************************************

* This do-file combines information from various data sets to 
	* compute the instrumental variable
	* get the main variables for analysis at Microregião level
	
***********************************************************
** Set globals for directories

global tables
global graphs 
global data

*set directory

cd 

***************************************************************************
*create municip data files from Excel sheets
clear
	//RAIS employment and wage data
tempfile t2003 t2004 t2005 t2006 t2007 t2008 t2009 t2010
	//RAIS employment and wage data
	forv y=2003/2010{
		import delimited using "$rais\MR-level\rais-`y'-microregions.csv", varnames(1)
		keep averagemonthlywage totalestablishments totaljobs year braid
		ren totaljobs numemp
		rename braid id
		save `t`y'', replace
		if `y'==2010{
			}
		else{
			clear
		}
	}
	forv y=2003/2009{
		append using `t`y''
	}
	sort id year
	replace id = upper(id)
	tempfile mrrais
		save `mrrais'
		clear
	import excel using "$rais\RAIS_MRcodes.xlsx", first
	rename IDIBGE micregion
		*remove one 0 in the middle of the MR code for later merge:
	tostring micregion, replace
	replace micregion=regexr(micregion,"0","")
	destring micregion, replace
	ren ID id
	sort micregion 
	drop C
	merge 1:m id using  `mrrais', nogen keep(3)
		tempfile xx
	save `xx', replace
	keep if micregion==52018 | micregion==29019
	collapse (sum ) numemp (mean) averagemonthlywage , by(year micregion)
	tempfile x2
	save `x2', replace
	use `xx', clear
	drop if micregion==52018 | micregion==29019
	append using `x2'
		drop id 
	save "$data\MR_RAIS_02-10.dta", replace
	
clear
	import excel using "$data\MC_Excel_dados\MR_population_00-09.xls", first
	drop Microregião Sigla
	rename Codigo micregion
	tokenize 2000 2001 2002 2003 2004 2005 2006 2008 2009
	local new 1
	foreach item in D E F G H I J K L{
		rename `item' population_``new''
		local ++new
	}
	save "$data\MR_population_00-09.dta", replace
	clear

	import excel using "$data\MC_Excel_dados\MR_population_07-10.xls", first
	drop Microregião Sigla
	rename Codigo micregion
	tokenize 2007 2010
	local new 1
	foreach item in D E{
		rename `item' population_``new''
		local ++new
	}
	sort micregion
	merge 1:1 micregion using "$data\MR_population_00-09.dta", nogen keep(3)
	destring micregion, replace
	save "$data\MR_population_allyears.dta", replace
	clear
	
	import excel using "$data\MC_Excel_dados\MR_homicides_03-09.xls", first
	drop Microregião Sigla
	rename Codigo micregion
	tokenize 2003 2004 2005 2006 2007 2008 2009
	local new 1
	foreach item in D E F G H I J{
		rename `item' homicrate_``new''
		local ++new
	}
	sort micregion
	destring micregion, replace
	save "$data\MR_homicides_03-09.dta", replace
	clear

	import excel using "$data\MC_Excel_dados\MR_homicides_N_03-09.xls", first
	drop Microregião Sigla
	rename Codigo micregion
	tokenize 2003 2004 2005 2006 2007 2008 2009
	local new 1
	foreach item in D E F G H I J{
		rename `item' homicides_``new''
		local ++new
	}
	destring micregion, replace
	save "$data\MR_homicidesN_03-09.dta", replace
	clear

** Generate local identifiers for region, state, microregion and microregiao level:
use "$data\MC-UF_code.dta", clear
	collapse (mean) uf, by(micregion)
	g region = 1 if uf>=11 & uf<=19
	replace region = 2 if uf>=21 & uf<=29
	replace region = 3 if uf>=31 & uf<=39
	replace region = 4 if uf>=41 & uf<=49
	replace region = 5 if uf>=50 & uf<=53
save "$data\MR_allcodes.dta", replace
use "$data\MC-UF_code.dta", clear
	g region = 1 if uf>=11 & uf<=19
	replace region = 2 if uf>=21 & uf<=29
	replace region = 3 if uf>=31 & uf<=39
	replace region = 4 if uf>=41 & uf<=49
	replace region = 5 if uf>=50 & uf<=53
save "$data\MC_allcodes.dta", replace

	clear
	import excel using "$data\MC_Excel_dados\MC_gdp_03-10.xls", first
		drop Município Sigla
		rename Codigo municip
		tokenize 2003 2004 2005 2006 2007 2008 2009 2010
		local new 1
		foreach item in D E F G H I J K{
			rename `item' gdp_``new''
			local ++new
		}
	merge m:1 municip using "$data\MC_allcodes.dta"
	collapse gdp_* , by(micregion)
	save "$data\MR_gdp_03-10.dta", replace
		clear

use "$data\MC_homicidios_2000-07-10.dta" , clear
merge 1:1 municip using "$data\MC_allcodes.dta", nogen keep(3)
collapse (mean) homicrate_2000 (sum) homic_2010 , by(micregion)
merge 1:1 micregion using "$data\MR_population_allyears.dta", nogen keep(3)
g homicrate_2010 = ((100000/population_2010)*homic_2010)
keep homicrate_2010 homicrate_2000 micregion
merge 1:1 micregion using "$data\MR_homicides_03-09.dta", nogen keep(3)
merge 1:1 micregion using "$data\MR_homicidesN_03-09.dta", nogen keep(3)
save "$data\MR_homicides_00-10.dta", replace

****************************************************************************
** generate distances for each origin-destination pair **

* 1. generate geocode file with MC code one for destination (id = mc) and one for destination (id = orig) including id, lat and long
* 2. merge these with the main Migration-shares file
* 3. use geodist to compute distance between origin and destination pairs (also try google traveltime)

	* merge geocodes with origin-destination migration data
	// 1. generate geocode file with MC code for destination (id = mc) 
use "$data\MR_coordinates.dta", clear
drop pop_size 
rename latitude Lat_mr
rename longitude Long_mr
sort micregion
tempfile MR
save `MR'

	// 1b. generate geocode file with MC code for origin (id = orig) 
use "$data\MR_coordinates.dta", clear
drop pop_size 
rename latitude Lat_orig
rename longitude Long_orig
sort micregion
ren micregion orig_mr
drop id 
tempfile ORIG
save `ORIG'

	// 2. merge these with migration share origin-destination matrix
** 1. : Origin-destination specific amount of migrants over period weighted using population survey weights ***
use "CENSO 2010_ind", clear
replace migrant=0 if orig_mr==micregion
drop if migrant==. | migrant==0
collapse (sum) migrant [pw=iweight], by(micregion orig_mr)

merge m:1 micregion using `MR', nogen keep(1 3)
merge m:1 orig_mr using `ORIG', nogen keep(1 3)

	// 3. compute simple geodesic distances between origins and destination on earth surface using geodist command
cap ssc install nearstat
cap ssc install geodist 
cap ssc install geonear

	geodist Lat_mr Long_mr Lat_orig Long_orig, g(distance)
	
drop Lat_mr Long_mr Lat_ori Long_ori
sort micregion orig_mr
drop migrant

save "$data\MR_distancematrix", replace

****************************************************************************
** 1. : Origin-destination specific amount of migrants over period weighted using population survey weights ***

use "CENSO 2010_ind", clear
*generate dummy for high educated individuals
g high=(educ_level>=3)
*generate base-year migrants: people who were born in different MR than current one and who moved before 2004
g basemigrant = (born_MC>=2 & time_MC>=6 & orig_mr!= micregion)
g basemigrantH = (born_MC>=2 & time_MC>=6 & orig_mr!= micregion & high==1)
g basemigrantL = (born_MC>=2 & time_MC>=6 & orig_mr!= micregion & high==0)
replace migrant=0 if orig_mr==micregion
*keep only variables that we need: origin, destination, year of migration
keep migrant basemigrant basemigrantH basemigrantL time_MC uf_ori uf orig_mr micregion high iweight
drop if migrant==. | migrant==0

merge m:1 micregion orig_mr using "$data\MR_distancematrix", nogen keep(1 3)

drop if distance==0

tempfile indiv
save `indiv'

* all migrants who left MC in period 2000-2003 (time_MC= 6-9) for specific microregiao c and who moved at least median distance: 252 km
	g migDall = (migrant==1 & time_MC>=6 & time_MC<=9 & distance>=252)
//same but for full period 2000-2009
** all migrants who left MC in period 2000-2009 (time_MC= 0-9) for specific microregiao c and who moved at least 252 km
	g migDT = (migrant==1 & time_MC>=0 & time_MC<=9 & distance>=252)
//same but only for study period 2004-2009
** all migrants who left MC in period 2004-2009 (time_MC= 0-5) for specific microregiao c and who moved at least 252 km
	g migDt = (migrant==1 & time_MC>=0 & time_MC<=5 & distance>=252)

collapse (sum) migDall migDT migDt ///
			[pw=iweight], by(micregion orig_mr)
		
	compress
save "$data\MR_Origin-destination-migration_FULLt", replace

*******************************************************************************
** 2. : we compute for each origin the total number of outmigrants over all years

use `indiv', clear

* all migrants who left MC in period 2000-2003 (time_MC= 6-9) for specific microregiao c and who moved at least median distance: 252 km
	g outDall = (migrant==1 & time_MC>=6 & time_MC<=9 & distance>=252)
//same but for full period 2000-2009
** all migrants who left MC in period 2000-2009 (time_MC= 0-9) for specific microregiao c and who moved at least 252 km
	g outDT = (migrant==1 & time_MC>=0 & time_MC<=9 & distance>=252)
//same but only for study period 2004-2009
** all migrants who left MC in period 2004-2009 (time_MC= 0-5) for specific microregiao c and who moved at least 252 km
	g outDt = (migrant==1 & time_MC>=0 & time_MC<=5 & distance>=252)

	*collapse to MC level by origing
collapse (sum) outDall outDT outDt [pw=iweight], by(orig_mr)
			
	tempfile x1
	save `x1'
	*generate migration rates relative to population in 2000
	use "$data\MR_population_allyears", clear
	keep micregion population_2000
	rename micregion orig_mr
	merge 1:1 orig_mr using `x1', nogen keep(3)

	foreach v in outDall outDT outDt {
		g r_`v' = ((100000/population_2000)*`v')
	}
	
	compress
save "$data\MR_Origin-outmigration_FULLt", replace
****************************************************************************
*** 3. : we compute for each destination the total number of In-migrants over all years

use `indiv', clear

*IN migration from perspective of destination microregiao
** all migrants who left MC in period 2000-2004 (time_MC= 6-9) for specific microregiao c and who moved at least 339km
	g inDall = (migrant==1 & time_MC>=6 & time_MC<=9 & distance>=252)
//same but for full period 2000-2009
** all migrants who left MC in period 2000-2009 (time_MC= 0-9) for specific microregiao c and who moved at least 252 km
	g inDT = (migrant==1 & time_MC>=0 & time_MC<=9 & distance>=252)
//same but only for study period 2004-2009
** all migrants who left MC in period 2004-2009 (time_MC= 0-5) for specific microregiao c and who moved at least 252 km
	g inDt = (migrant==1 & time_MC>=0 & time_MC<=5 & distance>=252)

		*collapse to MC level by origing
collapse (sum) inDall inDT inDt ///
		[pw=iweight], by(micregion)
			
	tempfile x1
	save `x1'
	*generate migration rates relative to population in 2000
	use "$data\MR_population_allyears", clear
	keep micregion population_2000
	merge 1:1 micregion using `x1', nogen keep(3)
	foreach v in inDall inDT inDt{
		g r_`v' = ((100000/population_2000)*`v')
	}
	compress
save "$data\MR_Destination-immigration_FULLt", replace

****************************************************************************
*** 4. : Merge these datasets into one
use "$data\MR_Origin-destination-migration_FULLt", clear
merge m:1 orig_mr using "$data\MR_Origin-outmigration_FULLt", nogen keep(1 3)  
merge 1:1 micregion orig_mr using "$data\MR_distancematrix", nogen keep(1 3)

*** 5. : Create destination-specific and origin-specific shares
g p_outDall = (migDall/outDall)
foreach p in T t{
	g p_outD`p' = (migD`p'/outD`p')
}

* keep only the shares as they will be used as weights or for predicting weights with distance
keep micregion orig_mr p_outDall p_outDT p_outDt distance

save "$data\MR_Migration-shares_FULLt", replace

****************************************************************************
*** Annual migration rates 
use `indiv', clear

* IN-migration: migrant numbers per metropolitan municip from perspective of destination
	*min. 252km distance
forv t=0/5{
	g inD_`t' = (migrant==1 & time_MC==`t' & distance>=252)
}

*create microregiao level data of migrant flows
collapse (sum) inD* [pw=iweight], by (micregion)
sort micregion

*rename ending so that it's by year
tokenize 2009 2008 2007 2006 2005 2004
	local new 1
	forv t=0/5{
		rename inD_`t' inD_``new''
		local ++new
	}

tempfile t2
save `t2'

*generate migration rates in each year:
	use "$data\MR_population_allyears", clear
merge 1:1 micregion using `t2', nogen keep(3)

forv y=2004/2009{
		g r_inD_`y' = ((100000/population_`y')*inD_`y')
	}

compress
save "$data\MR_IV_annualMigration_FULLt", replace
	
****************************************************************************
*Sectoral data and sectoral local shocks:
do "$do\dataprep_RAIS.do"

****************************************************************************
//Compute weighted IV for IN-migration

cap clear
cap clear matrix
cap clear mata
set matsize 10000
set maxvar 120000
use "$data\MR_Migration-shares_FULLt", clear
merge m:1 micregion using "$data\MR_sector_M_03-10", nogen keep(3)
merge m:1 micregion using "$data\MR_allcodes", nogen keep(3)

forv y=2004/2009{
		foreach t in all T t{
			//IV1: Kleemans/Magruder weighting - Bartik demand shock
			g iv_outD_`y' = p_outD`t' * MIVE`y'
			bysort micregion: egen MIVE_IND`t'_`y' = total(iv_outD_`y')
			drop iv_outD_`y'
		}
		g junk`y' = p_outDall * MIVE`y' if orig_mr!=23017 & orig_mr!=23010
		bysort micregion: egen MIVE_rob_`y' = total(junk`y')  
		drop junk`y'
	}

	//ROBUST IV: distance instead of past migration as weight
forv y=2004/2009{			
	g ivROB_out`y' = distance * MIVE`y'
	bysort micregion: egen MIVE_DIST_`y' = total(ivROB_out`y')
	drop ivROB_out`y' 
}			
*other national shock measure: wage growth
forv y=2004/2009{
	g iv_outD_`y' = p_outDall * MIV`y'
	bysort micregion: egen MIV_INDall_`y' = total(iv_outD_`y')
	drop iv_outD_`y'
}

*other level of shock measure: region 
forv y=2004/2009{
	g iv_outD_`y' = p_outDall * MRIVE`y'
	bysort micregion: egen MRIVE_INDall_`y' = total(iv_outD_`y')
	drop iv_outD_`y'
}

*FALSE IVs: 
forv w=1/1000{
	g p`w'_out = runiform()
}
forv w=1/1000{
	forv y=2004/2009{
				*FALSE: random sorting weights for migration probability
				g iv_out_`y' = p`w'_out * MIVE`y'
				bysort micregion: egen Fp`w'IN_`y' = total(iv_out_`y') 
				drop iv_out_`y' 
			}
		}
		
drop MIV20* MIVE20* MRIVE20* 
keep micregion MIVE* MIV* MRIV* Fp1IN_2004-Fp1000IN_2009 
gcollapse MIV* MRIV* Fp1IN_2004-Fp1000IN_2009 , by(micregion)

order micregion MIV_INDall_* MIVE_INDT_* MIVE_INDt_* MIVE_INDall_* MIVE_DIST_* MRIVE_INDall_* 

	unab vars04 : *2004
	local stubs4 : subinstr local vars04 "2004" "", all
reshape long `stubs4' , i(micregion) j(year)
		
xtset micregion year
 compress
save "$data\MR_PUSH-IV_panel_allsectors", replace

****************************************************************************

** other MC level information: 

**all population, not just working
use "D:\data\Brazil\Censo\Censo 2010\CENSO 2010_ind", clear
merge m:1 micregion using "$data\MR_allcodes", nogen keep(1 3)

g high=(educ_level>=3) // high and low skilled workers (with and without high school)
g LF = (work_active==1) // active labour force participants
g ymale = (sex==0 & age>=16 & age<=25 & high==0) //loweducated young male 

gcollapse LF ymale high nonwhite youth dropouts rent_v [pw=iweight], by(micregion)
tempfile lf
save `lf'

use "D:\data\Brazil\Censo\Censo 2010\CENSO 2010_ind", clear 
merge m:1 micregion using "$data\MR_allcodes", nogen keep(1 3)
drop if work_active==0 //only working active population

*gen dummies for variables that shall be aggregated to microregiao level, =1 for category we are interested in
	* g dummy for having high school degree:
	g high=(educ_level>=3)
	* g dummy for unemployed
	g unemployed=(work_emp_main==0)
	* g dummy for being young:
	g young = (age>=16 & age<=25)
	* g dummy for being young and unemployed
	g youngUE = (age>=16 & age<=25 & unemployed==1)
	* g dummy for being young, male and unemployed
	g ymaleUE= (youngUE==1 & sex==0)
	* g dummy for being young, male, low-educated and unemployed
	g ymaleleUE= (ymaleUE==1 & educ_high<3)
	*g dummy for being male, low-educated and unemployed
	g maleleUE= (unemployed==1 & sex==0 & educ_high<3)
	*g dummy for formal public job
	g public=(informal==1) 
		replace informal=0 if informal==1
		replace informal=1 if informal>=2 //informality (including no card, self-employed, small business <5)
g agriculture=(activ_group==1) //(agriculture)
g wageh = (inc_mth_v_main/4/work_hrs) //hourly wage
g lhwage = log(wageh) 
g lwage_inf = lhwage if informal==1
g lwage_f = lhwage if informal==0

rename area urban
gcollapse (mean) region uf young youngUE ymaleUE ymaleleUE maleleUE ///
				unemployed informal public agriculture urban lwage_inf lwage_f ///
				lhwage [pw=iweight], by(micregion)
sort micregion			
merge 1:1 micregion using `lf', nogen keep(3)

	* mark variables with year ending
foreach v in lwage_inf lwage_f lhwage high ymale LF urban young youngUE ymaleUE ymaleleUE maleleUE informal unemployed agriculture public nonwhite youth dropouts rent_v  {
	rename `v' `v'_2010
}

	* add geo-data coordinates
merge m:1 micregion using "$data\MR_coordinates.dta", keep(3) nogen
drop id MR pop_size
	* add data for previous years: homicides, population, annual migration, GDP
merge m:1 micregion using "$data\MR_homicides_00-10.dta", keep(3) nogen
merge m:1 micregion using "$data\MR_IV_annualMigration_FULLt", keep(3) nogen
merge m:1 micregion using "$data\MR_gdp_03-10.dta", keep(1 3) nogen
sort micregion

** reshape into panel
reshape long population_ homicrate_ homicides_ r_inD_ ymale_ young_ youngUE_ ymaleUE_ ymaleleUE_ maleleUE_ high_ loweduc_ agrilwage_ lhwage_ lwage_inf_ lwage_f_ gdp_ nonwhite_ youth_ dropouts_ rent_v_ urban_ agriculture_ public_ informal_ unemployed , i(micregion) j(year)

xtset micregion year

bysort micregion: g homic2000_ = homicrate_[1]
replace homic2000_ = 0 if homic2000_ ==.
drop if year==2000

*generate correct year dummies, as we are keeping 2006 only for IV
g DYear = year
replace DYear = . if year<=2004 

*merge with IV data
merge 1:1 micregion year using "$data\MR_PUSH-IV_panel_allsectors", nogen keep(1 3) //PUSH IVs
merge 1:1 micregion year using "$data\MR_RAIS_02-10", nogen keep(1 3) //RAIS employment data

** generate log of variables:
foreach v in homicrate_ r_inD_ population_ averagemonthlywage numemp gdp_{ 
	g l_`v' = log(`v')
}

tempfile main
save `main'

// merge in the sector share variable from RAIS:
use "$data\MR_sector_M_03-10", clear
keep micregion MRavgwage* MRavgjob* Mavgwage* Mavgjobs* MIV* MIVE* MRIV* MRIVE* Mempshare* 
reshape long MRavgwage MRavgjobs Mavgwage Mavgjobs MIV MIVE MRIV MRIVE Mempshare , i(micregion) j(year)
merge 1:1 micregion year using `main', nogen keep(2 3)

foreach v in MIV MIVE MRIVE MIV_INDall_ MIVE_INDall_ MIVE_INDT_ MIVE_INDt_ MIVE_DIST_ {  
	recode `v' .=0 
} 
foreach v of varlist Fp1IN_-Fp1000IN_ {
	recode `v' .=0
}

foreach var in  unemployed_ public_ agriculture_ urban_ lhwage_ lwage_inf_ lwage_f_  LF_ ymale_ young_ youngUE_ ymaleUE_ ymaleleUE_ maleleUE_ high_ nonwhite_ youth_ dropouts_ informal_{
	ren `var' `var'C
}

tempfile main
save `main'
	*merge PNAD data:
use "$data\PNAD_2001-09.dta", clear
merge m:1 municip using "$data\MC_allcodes.dta", nogen keep(3)
gcollapse (mean) rent_md active_ unemployed_ agriculture_ construction_ manufac_ manuwage_ lwage_ lhwage_ lhwageH_ lhwageL_ lwage_inf_ lwage_f_ highe_ highs_ young_ youngUE_ ymaleUE_ ymaleleUE_ maleleUE_ formal_ emp specsum_ PNAD , by(micregion year)

merge 1:1 micregion year using `main', nogen keep(1 2 3)

g formal_C=(1-informal_C)

*state trends
g trend=year-2004
tab uf, g(uf_)
forv s=1/27{
	g uf_`s'_t = uf_`s'*trend
}

g DYear2=year if year>=2004
*define state-time dummies
egen uf_year=group(uf DYear2)
*standardize local labor demand shock 
egen zMIVE = std(MIVE)

compress
save "$data\MR_panel_ALL_FULLt", replace

***********************************************
*To test Goldsmith-Pinkham et al. (2020) assumptions, need to get individual migration weights and shocks in wide format

use "$data\MR_panel_ALL_FULLt", clear

keep micregion year uf region uf_year l_homicrate_ l_population_ zMIVE MIVE_INDall_ MIVE_DIST_ MRIVE MRIVE_INDall_ l_r_inD_ population_ l_gdp_ l_averagemonthlywage l_numemp
tempfile temp1
save `temp1'

use "$data\MR_Migration-shares_FULLt", clear
merge m:1 orig_mr using "$data\MR_MIV_origin", nogen keep(3)
keep micregion orig_mr p_outDall
ren p_outDall pin
greshape wide pin , i(micregion) j(orig_mr)
merge 1:m micregion using `temp1', nogen keep(3)
tempfile temp2
save `temp2'

use "$data\MR_sector_M_03-10", clear
forv x=2003/2010{
	ren MIVE`x' shock`x'
}
ren micregion orig_mr
keep orig_mr shock*
greshape long shock, i(orig_mr) j(year)
greshape wide shock, i(year) j(orig_mr)
merge 1:m year using `temp2', nogen keep(3)

foreach v of varlist pin*{
    recode `v' (.=0)
}
egen zMRIVE = std(MRIVE)
drop MRIVE

lab var population_ "Microregiao population"
lab var MIVE_INDall_ "IV"
lab var l_homicrate_ "Log(Homicide rate)"
lab var l_r_inD_ "Log(In-migration rate)"
lab var l_population_ "Log(Population)"
lab var l_averagemonthlywage "Log(Average monthly wage)"
lab var l_numemp "Log(Number of formally employed workers)"
lab var l_gdp_ "Log(local GDP)"
lab var uf_year "State-year fixed effect"
lab var zMIVE "Standardized values of local labor"

*save this version for correlation tests and pre-trend tests:
compress
save "$data\MR_GPSStests_data", replace
	lab data "MR panel for Goldsmith-Pinkham et al. (2020) tests"

xtset micregion year
*get everything to same year as bartik_weight command does not allow to use time-series operators
foreach v in l_r_inD_ zMIVE MIVE_INDall_ MIVE_DIST_ zMRIVE MRIVE_INDall_{ //iv
    replace `v'=. if year==2010
	foreach x in 2009 2008 2007 2006 2005 2004{
		carryforward `v', replace
		replace `v'=. if year==`x'
	}
}
foreach v of varlist shock11001-shock53001 {
    replace `v'=. if year==2010
	foreach x in 2009 2008 2007 2006 2005 2004{
		carryforward `v', replace
		replace `v'=. if year==`x'
		replace `v'=`v'/100
	}
}

drop if year<2005

compress
save "$data\MR_GPSS_data", replace
	lab data "MR panel for Goldsmith-Pinkham et al. (2020) Rotemberg weights"
	
	
*done*
